package wzc.design_pattern.behaviour.state;

/**
 * @Author 那和不是个啥
 * @Date 2025/7/20
 * @Description
 */

public class VendingMachine {
    private VendingMachineState currentState;

    public VendingMachine() {
        // 初始状态是没有投币
        currentState = new NoCoinState(this);
    }

    public void setCurrentState(VendingMachineState state) {
        currentState = state;
    }

    // 操作委托给当前状态
    public void insertCoin() {
        currentState.insertCoin();
    }

    public void ejectCoin() {
        currentState.ejectCoin();
    }

    public void pressButton() {
        currentState.pressButton();
    }

    public void dispense() {
        currentState.dispense();
    }
}
